package model;

import java.sql.Timestamp;

/**
 * This is a builder class for Email.
 * 
 * The email builder class uses the builder design pattern to create an email object with 
 * multiple parameters.
 * @author buthainahaldosary
 * @since May 13, 2013
 * @version $Revision: 1.0 $
 */

public class EmailBuilder 
{
	 int id;
	 String to;
	 String from;
	 String subject;
	 String body;
	 boolean read;
	 Timestamp timestamp;
	 int folderId;
	 
	 /**
	  * Parameterless Constructor
	  */
	 public EmailBuilder(){
		 id = -1;
		 to = "";
		 from = "";
		 subject = "";
		 body = "";
		 read = true;
		 folderId = 0;
		 java.util.Date date= new java.util.Date();
		 timestamp = new Timestamp(date.getTime());
	 }

	 /**
	  * Sets the email to field 
	 
	 
	  * @param to String
	  * @return current email builder object. */
	public EmailBuilder setTo(String to) {
		this.to = to;
		return this;
	}

	/**
	 * Sets the email from field
	
	
	 * @param from String
	 * @return current email builder object. */
	public EmailBuilder setFrom(String from) {
		this.from = from;
		return this;
	}

	/**
	 * Sets the email subject field
	
	
	 * @param subject String
	 * @return current email builder object. */
	public EmailBuilder setSubject(String subject) {
		this.subject = subject;
		return this;
	}

	/**
	 * Sets the email body field
	
	
	 * @param body String
	 * @return current email builder object. */
	public EmailBuilder setBody(String body) {
		this.body = body;
		return this;
	}

	/**
	 * Sets the email read field
	
	
	 * @param read boolean
	 * @return current email builder object. */
	public EmailBuilder setRead(boolean read) {
		this.read = read;
		return this;
	}

	/**
	 * Sets the email timestamp field
	
	
	 * @param timestamp Timestamp
	 * @return current email builder object. */
	public EmailBuilder setTimestamp(Timestamp timestamp) {
		this.timestamp = timestamp;
		return this;
	}

	/**
	 * Sets the email folder id field
	
	
	 * @param folderId int
	 * @return current email builder object. */
	public EmailBuilder setFolderId(int folderId) {
		this.folderId = folderId;
		return this;
	}
	
	/**
	 * Sets the email id field
	
	
	 * @param id int
	 * @return current email builder object. */
	public EmailBuilder setId(int id){
		this.id = id;
		return this;
	}
	
	/**
	 * Build and return the email object
	
	 * @return email object that has been built. */
	public Email build(){
		
		Email email = new Email();
		email.setTo(to);
		email.setFrom(from);
		email.setBody(body);
		email.setSubject(subject);
		email.setTimestamp(timestamp);
		email.setRead(read);
		email.setFolderId(folderId);
		email.setId(id);
		return email;
	}

	/**
	 * Gets the to field
	
	 * @return to field */
	public String getTo() {
		return to;
	}

	/**
	 * Gets the from field
	
	 * @return from field */
	public String getFrom() {
		return from;
	}

	/**
	 * Gets the subject field
	
	 * @return subject field */
	public String getSubject() {
		return subject;
	}

	/**
	 * Gets the body field
	
	 * @return body field */
	public String getBody() {
		return body;
	}

	/**
	 * Gets the read field
	 *  
	@return read field */
	public Boolean isRead() {
		return read;
	}

	/**
	 * Gets the timestamp field
	
	 * @return time stamp field */
	public Timestamp getTimestamp() {
		return timestamp;
	}

	/**
	 * Gets the folder id field
	
	 * @return folder id field */
	public int getFolderId() {
		return folderId;
	}

	/**
	 * Gets the email id field
	
	 * @return email id field */
	public int getId() {
		return id;
	}
	 
}
